﻿using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using Serilog;
using Serilog.Formatting.Json;


namespace _068.日志Logging
{
	public class Program
	{
		static void Main(string[] args)
		{
			ServiceCollection services = new ServiceCollection();
			services.AddLogging(logBuilder =>
			{
				logBuilder.AddConsole();
				// 设置最小显示的级别  用了n log最后不要用这个
				// logBuilder.SetMinimumLevel(LogLevel.Trace);
				logBuilder.AddNLog();


				// 使用 Serilog
				//Log.Logger = new LoggerConfiguration()
				//   .MinimumLevel.Debug()
				//   .Enrich.FromLogContext()
				//   .WriteTo.Console(new JsonFormatter())
				//   .CreateLogger();
				//logBuilder.AddSerilog();


			});
			services.AddScoped<Test1>();

			using var sp = services.BuildServiceProvider();
			var test1 = sp.GetRequiredService<Test1>();
			test1.Test();
		}
	}
}
